function postComment(){
	var innerdocument = getNestedPage().contentDocument;
	var input = innerdocument.getElementById("commenttext");
	sendComment(input.value);
	input.value = "";
}


function showNewComments(comments){
	 fetchNewcommentsIntoTable(comments, 20);
}

function fetchNewcommentsIntoTable(comments, maxRows){
	var even = false;
	var innerdocument = getNestedPage().contentDocument;
	var table = innerdocument.getElementById("commentstablebody");
	for(var i = comments.length - 1;i > -1; i--){
		var row = table.insertRow(0);
		if(even = !even)
			row.setAttribute('class', 'alt');
		var cell1 = row.insertCell(0);
		cell1.innerHTML = comments[i].userDisplayName + ": " + comments[i].text ;
//		var cell2 = row.insertCell(1);
//		cell2.innerHTML = comments[i].text;
		var cell3 = row.insertCell(1);
		cell3.innerHTML = new Date(comments[i].date).toLocaleTimeString();
		
		if(table.rows.length > maxRows){
			table.removeChild(table.lastChild);
		}
		//so that we will keep only maxRows elements in the same table
	}
}

function  showPostCommentForm(){
	var innerdocument = getNestedPage().contentDocument;
	innerdocument.getElementById('postcomments').style.visibility = "visible";
}
